import Base from "../base.js";
import adminsApi from "../../api/admins.js";

export default class extends Base {
  render() {
    this.$el.html(`
    <section class="w3l-login">
		<div class="overlay">
			<div class="wrapper">
				<div class="logo">
				</div>
				<div class="form-section">
					<h3>Reg</h3>
		
						<div class="form-input">
							<input type="text" name="Username" placeholder="请输入账号" value="z3" >
						</div>
						<div class="form-input">
							<input type="password" name="password" placeholder="密码"value="123" >
						</div>
						<div class="form-input">
							<input type="password" name="phone" placeholder="请输入手机号" >
						</div>
						<div>
						<button class=" btn-primary theme-button ">获取验证码</button>	<input type="password" name="phone" placeholder="请输入验证码"  id="useNum">
						</div>
						<button class="btn btn-primary theme-button mt-4" id="reg-btn">注册</button>
				
				</div>
			</div>
		</div>
	  <div id="stars"></div>
    <div id="stars2"></div>
    <div id="stars3"></div>
	</section>

        `)
    this.$usernameEle = $("input[name=Username]");
    this.$passwordEle = $("input[name=password]");
    this.$regBtn = $("#reg-btn");
  }

 
  async regHandle() {
    let username = this.$usernameEle.val();
    let password = this.$passwordEle.val();
	console.log({username,password});
    const status = await adminsApi.reg({ username, password })
	console.log(status)
	if(status){
		alert("注册成功")
		location.hash="#/login"
	}else{
		alert("注册失败")
	}

  }
  handle() {

    this.$regBtn.on("click", this.regHandle.bind(this));
  }


  
}














